<!DOCTYPE html>
<html>
    <head lang="en">
        <meta charset="UTF-8">
        <meta name="csrf-token" content="{{ csrf_token() }}">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> 
        <meta name="apple-mobile-web-app-capable" content="yes">
        <link rel="shortcut icon" type="image/x-icon" href="{{URL::asset('handan/images/logo-icon.png')}}" />
        <title>分析师</title>
        <link rel="stylesheet" href="{{URL::asset('newmobile/css/public.css') }}"/>
        <link rel="stylesheet" href="{{URL::asset('newmobile/css/rankdetail.css') }}"/>
        <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm.min.css">
        <script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
    </head>
<body>

<div class="page-group">
    <div id="page-infinite-scroll-bottom" class="page">
        <div class="content infinite-scroll" data-distance="100">
            <div class="list-block">
                <ul class="list-container">
                    <!--<li></li>-->
<!--                     <li onclick="langxue(this)">
                       <section>
                        <div class="list"> 
                         <div class="type">
                          <p>中文名</p>
                          <p>英文名</p>
                         </div> 
                         <div class="direction"> 
                          <p>卖出</p> 
                          <p>方向</p>
                         </div> 
                         <div class="profit"> 
                          <div style="color:#F0364C;">
                           25
                          </div> 
                          <p>盈利</p>
                         </div>
                        </div> 
                        <div class="detail">
                            <div class="detail_top">
                                <div class="detail_top_left"> 
                                    <div>
                                        <p>开仓价</p>
                                        <p>111.11</p>
                                    </div> 
                                    <div>
                                        <p>止&nbsp;&nbsp;&nbsp;盈</p>
                                        <p>222.22</p>
                                    </div> 
                                    <div>
                                        <p>止&nbsp;&nbsp;&nbsp;损</p>
                                        <p>99</p>
                                    </div>
                                    <div>
                                        <p>订单号</p>
                                        <p>A12345678</p>
                                    </div>
                                </div> 
                                <div class="detail_top_right"> 
                                    <div>
                                        <p>平&nbsp;&nbsp;仓&nbsp;&nbsp;价</p>
                                        <p>333.33</p>
                                    </div> 
                                    <div>
                                        <p>开仓时间</p>
                                        <p>2017-01-02 02:03:02</p>
                                    </div> 
                                    <div>
                                        <p>平仓时间</p>
                                        <p>2017-01-02 02:03:02</p>
                                    </div>
                                </div>
                            </div> 
                         
                        </div>
                       </section>
                       </li>-->
                </ul>
            </div>
            <!-- 加载提示符 -->
            <div class="infinite-scroll-preloader">
                <div class="preloader">
                </div>
            </div>
        </div>
    </div>
</div>
<div style="height: 9rem;"></div>
@include('newmobile.footer')
<!-- js引入 -->
<script src="{{URL::asset('mobile/js/public.js') }}"></script>
<script src='//g.alicdn.com/msui/sm/0.6.2/js/sm.min.js' charset='utf-8'></script>
<script>
var pagess = 1;
var allpage = 2;
var loading = false;
$(function () {
    'use strict';
    //无限滚动
    $(document).on("pageInit", "#page-infinite-scroll-bottom", function(e, id, page) {
//      var loading = false;
        // 每次加载添加多少条目
        var itemsPerLoad = 10;
        // 最多可加载的条目
        var lastIndex = $('.list-container li').length;
        pullupRefresh(0); //先加载一次数据
        $(page).on('infinite', function() {
            // 如果正在加载，则退出
            if (loading) return;
            // 设置flag
            loading = true;
            // 模拟1s的加载过程
            setTimeout(function() {
                // 重置加载flag
                loading = false;
                if (pagess >= allpage) {
                    // 加载完毕，则注销无限加载事件，以防不必要的加载
                    $.detachInfiniteScroll($('.infinite-scroll'));
                    // 删除加载提示符
                    $('.infinite-scroll-preloader').html('已加载全部');
                    return;
                }
                pagess++; //页面+1
                pullupRefresh(0);//更新数据
                // 更新最后加载的序号
                lastIndex = $('.list-container li').length;
                $.refreshScroller();
            }, 1000);
        });
    });
    //加载提示符
    $(document).on("pageInit", "#page-preloader", function(e, id, page) {
        $(page).on('click','.open-preloader-title', function () {
            $.showPreloader('加载中...')
            setTimeout(function () {
                $.hidePreloader();
            }, 2000);
        });
        $(page).on('click','.open-indicator', function () {
            $.showIndicator();
            setTimeout(function () {
                $.hideIndicator();
            }, 2000);
        });
    });
    $.init();
});
var select_type = 0, //交易类型 全局变量
    select_dealtype = 0; //订单盈利亏损 全局变量

//数据加载
var listurl       = '{{url("/showdetailinfo")}}';
var id = '{{$userid}}';
function pullupRefresh(num){
    $.ajax({
        url: listurl,
        type: "post",
        data:  {analyst_id:id,page:pagess},
        headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
        dataType:'json',
        success: function (data) {
            allpage = data.allpage;
            if(allpage < 2){
                $('.infinite-scroll-preloader').html('已加载全部');
            }else{
                $('.infinite-scroll-preloader').html('<div class="preloader"></div>');
            }
            var str='';
            var dataArr = data.arr;
                if(data){
                    for(var i=0;i<dataArr.length;i++) {
                        var data = dataArr;
                        str+='<li onclick="langxue(this)"><section><div class="list">';
                        str+='<div class="type"><p>'+data[i].chinaname+'</p><p>'+data[i].typename+'</p></div>'; //品种英文
                        str+='<div class="direction">';
                        if(data[i].buy_status == 1){
                            str += '<p>卖出</p>';
                        }else{
                            str += '<p>买入</p>';
                        }
                        str+='<p>方向</p></div>';
                        str+='<div class="profit">';
                        if(data[i].final_point >0 ){
                            str += '<div style="color:#F0364C;">'+data[i].final_point+'</div>';
                        }else{
                            str += '<div style="color:#3EB581;">'+data[i].final_point+'</div>';
                        }
                        str+='<p>盈利</p></div></div>';
                        str+='<div class="detail"><div class="detail_top"><div class="detail_top_left">';
                        str+='<div><p>开仓价</p><p>'+data[i].begin_point+'</p></div>'; //开仓价格
                        str+='<div><p>止&nbsp;&nbsp;&nbsp;盈</p><p>'+data[i].target_profit_point+'</p></div>';
                        str+='<div><p>止&nbsp;&nbsp;&nbsp;损</p><p>'+data[i].target_loss_point+'</p></div>';
                        str+='<div><p>订单号</p><p>'+data[i].tradeid+'</p></div></div>';
                        str+='<div class="detail_top_right">';
                        str+='<div><p>平&nbsp;&nbsp;仓&nbsp;&nbsp;价</p><p>'+data[i].end_point+'</p></div>'; //平仓价格
                        str+='<div><p>开仓时间</p><p>'+UnixToDate(data[i].begin_time,false,'',1)+' '+UnixToDate(data[i].begin_time,true,'',0)+'</p></div>';
                        str+='<div><p>平仓时间</p><p>'+UnixToDate(data[i].end_time,false,'',1)+' '+UnixToDate(data[i].end_time,true,'',0)+'</p></div></div></div>';
                        str+='</div></section></li>';
                    }
                }else{
                    $('.list-container').html('sorry，没有更多数据了');
                }
                if(num == 1){
                    $('.list-container').html(str);
                }else{
                    $('.list-container').append(str);
                }
            }
        });
};
//时间转换方法
function UnixToDate(unixTime, isFull, timeZone,type) {
    if (typeof (timeZone) == 'number')
    {
        unixTime = parseInt(unixTime) + parseInt(timeZone) * 60 * 60;
    }
    var time = new Date(unixTime * 1000);
    var ymdhis = "";
    if(type){
        ymdhis += time.getFullYear() + ".";
        ymdhis += (time.getMonth()+1)>9?(time.getMonth()+1)+'.':'0'+(time.getMonth()+1) + ".";
        ymdhis += time.getDate()>9?time.getDate():'0'+time.getDate();
    }
    if (isFull === true)
    {
        ymdhis += " " + time.getHours()>9?time.getHours()+ ":":'0'+time.getHours() + ":";
        ymdhis += time.getMinutes()>9?time.getMinutes()+ ":":'0'+time.getMinutes() + ":";
        ymdhis += time.getSeconds()>9?time.getSeconds():'0'+time.getSeconds();
    }
    return ymdhis;
}     
function langxue(obj) {
    $(obj).find('.detail').toggle();
}
</script>  
<style type="text/css">
body {
    background: #171922; 
}
.list-block {
    margin: 0;
} 
.list-block ul {
    background: #171922;
}
.list-block ul:after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    right: auto;
    top: auto;
    height: 0.021rem;
    width: 100%;
    background-color: #7390a4;
    display: block;
    z-index: 15;
    -webkit-transform-origin: 50% 100%;
    transform-origin: 50% 100%;
}
.page, .page-group {
    background: #171922;
    height: 95%;
}
body section div.detail div.detail_bottom .dingdannum {
  margin: 0rem;
}
footer {
    z-index: 999999;
}
/*底部行情应用样式*/
footer ul li:nth-child(1) a {
    color: #3B9CE0;
}
footer ul li:nth-child(1) a i {
  background: url("{{URL::asset('mobile/image/fxs_icond.png')}}") no-repeat center / cover;
}
</style>     
</body>
</html>
